package com.dyn.videohub.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum UserType {
    VIP(1,"网站会员"),
    COMMON_USER(0,"普通用户");

    private final Integer code;
    private final String name;


    /**
     * 获取当前类型
     * @param code 特征码
     * @return 用户类型
     */

    public static UserType of(Integer code){
        return Stream.of(values()).
                filter(bean -> bean.code.equals(code))
                .findAny()
                .orElse(null);
    }
}
